<html>
<head><meta charset="utf-8"><title>determine nounwind functions · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/determine.20nounwind.20functions.html">determine nounwind functions</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="146798236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/determine%20nounwind%20functions/near/146798236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/determine.20nounwind.20functions.html#146798236">(Nov 05 2018 at 14:23)</a>:</h4>
<p>I think it would be nice if we could determine that functions cannot unwind (panic), in order to drop unnecessary landing pads. Something similar to the PruneEH pass in LLVM.</p>
<p>However, I'm not sure how to best do this within the query framework. Assuming for now that SCCs should always yield the conservative result, would it be fine to make use of the query cycle detection for that?</p>



<a name="146817231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/determine%20nounwind%20functions/near/146817231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/determine.20nounwind.20functions.html#146817231">(Nov 05 2018 at 19:22)</a>:</h4>
<p>Not sure what SCCs are, but using the query cycle detector for anything but aborting compilation entirely is evil (I've been told).</p>



<a name="146817423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/determine%20nounwind%20functions/near/146817423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/determine.20nounwind.20functions.html#146817423">(Nov 05 2018 at 19:25)</a>:</h4>
<p>The best I can come up with is to use the mir_optimized query and recurse on the MIR you get back (putting all the seen DefIds in a hashset to detect recursion and duplicate calls). This sadly doesn't scale well, because you're redoing the recursion detection on MIRs that you've done it before in another query</p>



<a name="146822922"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/determine%20nounwind%20functions/near/146822922" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/determine.20nounwind.20functions.html#146822922">(Nov 05 2018 at 20:51)</a>:</h4>
<blockquote>
<p>what SCCs are,</p>
</blockquote>
<p>By previous context, I'd guess <a href="https://en.wikipedia.org/wiki/Strongly_connected_component" target="_blank" title="https://en.wikipedia.org/wiki/Strongly_connected_component">strongly connected component</a></p>



<a name="146824191"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/determine%20nounwind%20functions/near/146824191" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/determine.20nounwind.20functions.html#146824191">(Nov 05 2018 at 21:11)</a>:</h4>
<p>Yeah, I meant strongly connected components. A lot of call graph oriented optimizations like to partition the cyclic call graph as an acyclic graph of SCCs, so that the acyclic (generally easy) and cyclic (generally hard) parts can be treated separately.</p>



<a name="147543752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/determine%20nounwind%20functions/near/147543752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/determine.20nounwind.20functions.html#147543752">(Nov 12 2018 at 18:44)</a>:</h4>
<p>we have in general a need for being able to find SCCs of the callgraph; we need it for inlining too</p>



<a name="147543753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/determine%20nounwind%20functions/near/147543753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/determine.20nounwind.20functions.html#147543753">(Nov 12 2018 at 18:44)</a>:</h4>
<p>there is SCC code in <code>rustc_data_structures</code></p>



<a name="147543754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/determine%20nounwind%20functions/near/147543754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/determine.20nounwind.20functions.html#147543754">(Nov 12 2018 at 18:45)</a>:</h4>
<p>just need to model the graph</p>



<a name="147543767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/determine%20nounwind%20functions/near/147543767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/determine.20nounwind.20functions.html#147543767">(Nov 12 2018 at 18:45)</a>:</h4>
<p>I've chatted with <span class="user-mention" data-user-id="125250">@Wesley Wiser</span> about doing this from time to time</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>